<%@ page import="examinee.ExamineeInfo" %>
<%@ page import="com.opensymphony.xwork2.util.ValueStack" %>
<%@ page import="exam.AnswerPaperInfo" %>
<%@ page import="java.util.List" %>
<%@ page import="exam.TestPaperInfo" %>
<%@ page import="exam.ExamVar" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
  <title>考试系统</title>
  <link href="../skin/default/global.css" rel="stylesheet" type="text/css"/>
  <link href="../skin/default/layout.css" rel="stylesheet" type="text/css"/>
   <script>
    	//页面载入后记录一个时间
	var Record_start_time = new Date().getTime();
    </script>
  <script type="text/javascript" src="../common/exam.js"></script>
  <style>
    html, body {
      overflow: hidden;
    }
    
  </style>
</head>
<%
  ValueStack vs = (ValueStack) request.getAttribute("struts.valueStack");
  ExamineeInfo einfo = (ExamineeInfo) vs.findValue("einfo");
  TestPaperInfo tinfo = (TestPaperInfo) vs.findValue("tinfo");
  List<AnswerPaperInfo> alist = (List<AnswerPaperInfo>) vs.findValue("alist");
%>
<body class="exam">
<div id="notice">
  <div class="box">
    <div class="inner">
      <span id="noticeBox">考试时间已到，禁止答题！</span>
    </div>
  </div>
</div>
<div id="mask"></div>
<h1 class="header">
  <div class="examsend" id="examsend" onClick="EXAM.sendExam(true)"></div>
  <img src="../skin/default/exam-logo.gif"/>
  <span id="loading">试题数据加载中...</span>
</h1>

<div class="sidebar">

  <div class="panel">
    <h2>考生信息</h2>

    <div class="body">
      <ul>
        <li><b>姓名：</b><%=einfo.getEname()%></li>

        <li><b>考号：</b><%=einfo.getZkzh()%></li>
      </ul>
    </div>
  </div>

  <div class="panel">
    <h2>考试信息</h2>

    <div class="body">
      <ul>
        <li>剩余时间：<strong id="showtime"></strong></li>
      </ul>

      <table cellpadding="0" width="100%" cellspacing="0">
        <tbody>
          <%
            int row = alist.size() % 10 == 0 ? alist.size() / 10 : alist.size() / 10 + 1;
            for(int i = 0; i < row; i++){
          %>
          <tr>
            <%
              for (int j = 1; j <= 10; j++) {
                int index = i * 10 + j;
            %>
            <td id="exam_<%=index%>" <%=j == 10 ? "class=\"last\"" : ""%> onClick="linkQuestion('<%=index%>')">
              <%=index <= alist.size() ? String.valueOf(index) : ""%>
            </td>
            <%
              }
            %>
          </tr>
          <%
            }
          %>
        <tbody>
      </table>
      <ul>
        <li style="font-size:13px;color:#000"><b>蓝色为已做题目，白色为未作题目</b></li>
      </ul>
    </div>
  </div>

</div>
<div class="content" id="content">
</div>
<form name="sendForm" method="post" target="submitframe" action="handInTest.action" id="sendForm">
	
</form>
<div id="Customconfirm" style="display:none; cursor: default"> 
        <h1>你确定要交卷吗？</h1> 
    	<div>
    	<input type="button" id="yes" onclick="EXAM.closeconfirmSubmit()" value="确定" /> 
        <input type="button" id="no" onclick="EXAM.closeconfirmNOSubmit()" value="取消" /> 
    	</div>
</div> 
<iframe name="submitframe" style="display:none"></iframe>
<script type="text/javascript" src="../common/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="../common/jquery.blockUI.js"></script>
<script type="text/javascript">
  /*加载状态控制*/
  $("#loading").ajaxStart(function() {
    $(this).show();
  });
  $("#loading").ajaxError(function(event, request, settings) {
    $(this).html("试题加载出错，请联系系统管理员。");
  });
  $("#loading").ajaxSuccess(function() {
    $(this).hide();
  });
  $(function() {

    $("td").hover(function() {
      $(this).addClass("hover")
    },
            function() {
              $(this).removeClass("hover")
            }
            )

    $("#examsend").hover(function() {
      $(this).addClass("hover")
    }, function() {
      $(this).removeClass("hover")
    })
  })

  var EXAM = new exam.test()
  EXAM.loadExam("getQuestion.action?index=1")
  //系统时脉设置
  EXAM.stimeout("keepAlive.action", <%=ExamVar.TEST_INTERVAL%>)

  //EXAM.setExamType(false)
  //EXAM.setAnswer("R")
  //设定目标时间(数组元素)
  //target[target.length]=new Date(年,月-1,日,时,分,秒).getTime()
  
  //这里就是考试时间
  exam.target[exam.target.length] = <%=tinfo.getExamTime() - tinfo.getTime()%>

  //设定倒计时显示地址(数组元素)
  exam.time_id[exam.time_id.length] = "showtime";
  
  function linkQuestion(i){
  	var ind = $('#indexinput').val()//当前题目序列号
  	var ans = $('#answerinput').val();//当前题目的答案
  	EXAM.loadExam('fillAnswer.action?index='+ind+'&answer='+ans+'&to='+i+'')
  }

</script>

</body>

</html>
